#include<stdio.h>
void question1(int data[][10],int n,int Max_source[6]){
	for(int i=0;i<6;i++){
		for(int j=0;j<n;j++){
			if(Max_source[i]<data[j][i])
				Max_source[i]=data[j][i];
		}
	}
	char* class[6]={"语文","数学","英语","物理","化学","生物"};
	for(int i=0;i<6;i++){
		printf("%s的最高分是：%d \n",class[i],Max_source[i]);
	}
}
void question2(int data[][10],int n,int Desc_yuwen[10]){
	int tem[n];
	for(int i=0;i<n;i++){
		tem[i]=data[i][0];
	}
	for(int i=0;i<n;i++){
		int index=0;
		for(int j=0;j<n;j++){
			if(data[index][0]<data[j][0]){
				index=j;
			}
		}
		Desc_yuwen[i]=index;
		data[index][0]=0;
	}
	for(int i=0;i<n;i++){
		data[i][0]=tem[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<9;j++)
		  printf("%d ",data[Desc_yuwen[i]][j]);
		printf("\n");
	}
}
void question3(int data[][10],int n,int weight[]){
	for(int i=0;i<n;i++){
		int w=0;
		for(int j=0;j<6;j++){
			w+=weight[j]*data[i][j];
		}
		data[i][9]=w;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			printf("%d ",data[i][j]);
		}
		printf("\n");
	}
}
int get(){
	int n;
	char c;
	while(1){
		c=getchar();
		if(c=='0'||c=='1'||c=='2'||c=='3'){
	 		n=c-'0';
			while(c=getchar()!='\n');
	 		return n;
		}
		else {
			printf("请输入正确数字\n");
			while(c=getchar()!='\n');
		}
	}
}
int main(){
	int data[][10]={{110,92,92,90,78,75,537,55,1},{99,110,75,95,90,63,532,59,2},{96,88,90,87,83,69,513,78,3},{99,78,92,87,81,70,507,85,4},{98,82,100,83,80,58,501,87,5},{83,112,79,84,73,68,499,90,6},{94,84,76,72,80,76,482,97,7},{83,104,78,73,79,64,481,99,8},{90,100,91,69,64,57,471,107,9},{97,96,76,75,64,62,470,108,10}};
	int Max_source[6]={0};
	int Desc_yuwen[10]={0};//按照语文成绩顺序输出的标号
	int weight[] ={5,5,5,4,4,3};//权重
	int flag=1;
	while(flag){
		printf("请输入问题序号\n");
		printf("1.问题一\n");
		printf("2.问题二\n");
		printf("3.问题三\n");
		printf("0.退出\n");
		int selection=get();
		switch(selection){
			case 1:question1(data,10,Max_source); break;
			case 2:question2(data,10,Desc_yuwen);break;
			case 3:question3(data,10,weight); break;
			case 0:flag=0;break;
		}
	}
}
